/**
 * Created with IntelliJ IDEA.
 * User: Nikita.Brazhnikov
 * Date: 8/1/13
 * Time: 5:52 PM
 */
$(function() {
    $("div#content").on('focusout', '.contentBlock.editableContentWrapper', onEditableFocusOut);
    $("div#content").on('click', '.cmd-addBlock', onAddBlock);
});
function onEditableFocusOut() {
    var textContent = new TextContent(this);
    if (textContent.isEmpty()) {
        textContent.delete();
    }
}
function onAddBlock() {
    $lastContent = $("div#content").find('.contentBlock').last();
    var candidate = $('#samples').find('.contentBlock.candidate').first().clone();
    if ($lastContent.size() != 0) {
        candidate.insertAfter($lastContent);
    } else {
        candidate.appendTo("div#content");
    }
}

